import java.lang.instrument.Instrumentation;

public class AgentApplication { // https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html
    public static void premain(String arg, Instrumentation instrumentation) {
        System.err.println("agent startup , args is " + arg);
    }

    public static void agentmain(String arg, Instrumentation instrumentation) {
        System.err.println("agent startup , args is " + arg);
        Class<?>[] classes = instrumentation.getAllLoadedClasses();
        for (Class<?> cls : classes) System.out.println(cls.getName());
    }
}